<?php
/**
 * Group-Person's Model
 *
 * @category    IPB_CMS
 * @package     Application_Model
 * @copyright   Copyright (c) 2009 IPB CMS <http://ipb-cms.googlecode.com/>
 * @license     http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
 * @author      Henrique Moody <henriquemoody@gmail.com>
 */
class Model_GroupPerson extends App_Model_Abstract
{

    /**
     * Group's Model
     *
     * @var Model_Group
     */
    protected $_group;

    /**
     * Person's Model
     *
     * @var Model_Person
     */
    protected $_person;

    /**
     * Sets the model group
     *
     * @param Model_Group $group
     * @return Model_GroupPerson Fluent interface, returns self
     */
    public function setGroup(Model_Group $group)
    {
        $this->_group = $group;
        return $this;
    }

    /**
     * Returns the model group
     *
     * @return Model_Group
     */
    public function getGroup()
    {
        if (!$this->_group instanceof Model_Group) {
            $this->setGroup(new Model_Group());
        }
        return $this->_group;
    }

    /**
     * Sets the group ID
     *
     * @param integer $groupId ID of the group
     * @return Model_GroupPerson Fluent interface, returns self
     */
    public function setGroupId($groupId)
    {
        $this->getGroup()->setId($groupId);
        return $this;
    }

    /**
     * Returns the group ID
     *
     * @return integer|null Group ID
     */
    public function getGroupId()
    {
        return $this->getGroup()->getId();
    }

    /**
     * Sets the person's model
     *
     * @param Model_Person $person
     * @return Model_GroupPerson Fluent interface, returns self
     */
    public function setPerson(Model_Person $person)
    {
        $this->_person = $person;
        return $this;
    }

    /**
     * Returns the person's model
     *
     * @return Model_Person
     */
    public function getPerson()
    {
        if (!$this->_person instanceof Model_Person) {
            $this->setPerson(new Model_Person());
        }
        return $this->_person;
    }

    /**
     * Sets the person ID
     *
     * @param integer $personId ID of the person
     * @return Model_GroupPerson Fluent interface, returns self
     */
    public function setPersonId($personId)
    {
        $this->getPerson()->setId($personId);
        return $this;
    }

    /**
     * Returns the person ID
     *
     * @return integer Person ID
     */
    public function getPersonId()
    {
        return $this->getPerson()->getId();
    }

}
